import java.util.ArrayList;

/**
 * Created by rob on 02/06/14.
 */
public class IntroductoryExercises {

    void easiest_exercise_ever(){
        System.out.println("*");
    }

    void draw_a_horizontal_line(int n){
        while (n > 0){
            System.out.print("*");
            n--;
        }
        System.out.println();
    }

    void draw_a_vertical_line(int n){
        while (n > 0){
            easiest_exercise_ever();
            n--;
        }
    }

    void draw_a_right_triangle(int n){
        for (int i = 1; i <= n; i++){
            draw_a_horizontal_line(i);
        }
    }

    void upper_diamond(int n){
        for (int row = 1; row < n; row++){
            for (int j = 0; j < n - row; j++) {
                System.out.print(" ");
            }
            draw_a_horizontal_line(2*row - 1);
        }
    }

    void lower_diamond(int n){
        for (int space = 1; space < n; space++){
            for (int j = 0; j < space; j++){
                System.out.print(" ");
            }
            draw_a_horizontal_line(2*n - 1 - 2*space);
        }
    }

    void isosceles_triangle(int n){
        upper_diamond(n);
        draw_a_horizontal_line(2*n - 1);
    }

    void diamond(int n){
        isosceles_triangle(n);
        lower_diamond(n);
    }

    void diamond_with_name(int n){
        upper_diamond(n);
        System.out.println("Rob");
        lower_diamond(n);
    }

    void FizzBuzz(){
        for (int i = 1; i <= 100; i++){
            boolean d3 = i % 3 == 0;
            boolean d4 = i % 5 == 0;
            if (d3 || d4) {
                if (i % 3 == 0)
                    System.out.print("Fizz");
                if (i % 5 == 0)
                    System.out.print("Buzz");
            }
            else
                System.out.print(i);
            System.out.println();
        }
    }

    void get_primes(int n, ArrayList<Integer> primes) {
        if (n >= 2) {
            boolean prime_found = false;
            for (int i = 2; i <= n && !prime_found; i++) {
                if (n % i == 0){
                    primes.add(i);
                    prime_found = true;
                    get_primes(n/i, primes);
                }
            }
        }
    }

    //Prime Factors Exercise
    ArrayList<Integer> generate(int n) {
        ArrayList<Integer> primes = new ArrayList<Integer>();
        get_primes(n, primes);
        return primes;
    }

    void print_prime_factors(int n){
        ArrayList<Integer> primes = generate(n);
        for (int prime : primes){
            System.out.print(prime + " ");
        }
        System.out.println();
    }

    public static void main (String [] args) {
        IntroductoryExercises i = new IntroductoryExercises();
        i.easiest_exercise_ever();
        i.draw_a_horizontal_line(3);
        i.draw_a_vertical_line(3);
        i.draw_a_right_triangle(3);
        i.isosceles_triangle(3);
        i.diamond(3);
        i.diamond_with_name(3);
        i.FizzBuzz();
        for (int j = 1; j <= 32; j++){
            System.out.print(j + ": ");
            i.print_prime_factors(j);
        }

    }

}

